from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
import json

if __name__ == '__main__':

    ann_file = '../out/data/datasets/banana-detection/validate/annotations.json'

    coco_gt = COCO(ann_file)


    result_file = './results.json'

    coco_dt = coco_gt.loadRes(result_file)

    image_ids = coco_gt.getImgIds()

    ann_type = 'bbox'

    coco_eval = COCOeval(coco_gt, coco_dt, ann_type)

    coco_eval.params.imgIds = image_ids

    coco_eval.evaluate()

    coco_eval.accumulate()

    coco_eval.summarize()

